<?php
// +---------------------------------------------------------------------+
// | ALINEJUN    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/ALINEJUN                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 风景控制器
 */
class Scenery extends AdminBase
{
    
    /**
     * 风景列表
     */
    public function sceneryList()
    {
        
        $where = $this->logicScenery->getWhere($this->param);
        
        $this->assign('list', $this->logicScenery->getSceneryList($where, 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
        
        return $this->fetch('scenery_list');
    }
    
    /**
     * 风景添加
     */
    public function sceneryAdd()
    {
        
        $this->sceneryCommon();
        
        return $this->fetch('scenery_edit');
    }
    
    /**
     * 风景编辑
     */
    public function sceneryEdit()
    {
        
        $this->sceneryCommon();
        
        $info = $this->logicScenery->getSceneryInfo(['a.id' => $this->param['id']], 'a.*,m.nickname,c.name as category_name');
        
        !empty($info) && $info['img_ids_array'] = str2arr($info['img_ids']);
        
        $this->assign('info', $info);
        
        return $this->fetch('scenery_edit');
    }
    
    /**
     * 风景添加与编辑通用方法
     */
    public function sceneryCommon()
    {
        
        IS_POST && $this->jump($this->logicScenery->sceneryEdit($this->param));
        $city_select = $this->logicCity->cityToSelect($this->cityListTree);
        $this->assign('city_select', $city_select);
        $this->assign('scenery_category_list', $this->logicScenery->getSceneryCategoryList([], 'id,name', '', false));
    }
    
    /**
     * 风景分类添加
     */
    public function sceneryCategoryAdd()
    {
        
        IS_POST && $this->jump($this->logicScenery->sceneryCategoryEdit($this->param));
        
        return $this->fetch('scenery_category_edit');
    }
    
    /**
     * 风景分类编辑
     */
    public function sceneryCategoryEdit()
    {
        
        IS_POST && $this->jump($this->logicScenery->sceneryCategoryEdit($this->param));
        
        $info = $this->logicScenery->getSceneryCategoryInfo(['id' => $this->param['id']]);
        
        $this->assign('info', $info);
        
        return $this->fetch('scenery_category_edit');
    }
    
    /**
     * 风景分类列表
     */
    public function sceneryCategoryList()
    {
        
        $this->assign('list', $this->logicScenery->getSceneryCategoryList());
       
        return $this->fetch('scenery_category_list');
    }
    
    /**
     * 风景分类删除
     */
    public function sceneryCategoryDel($id = 0)
    {
        
        $this->jump($this->logicScenery->sceneryCategoryDel(['id' => $id]));
    }
    
    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('Scenery', $this->param));
    }
}
